package action;

import controller.Action;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Avaliacao;
import model.Turma;

public class ManterNotaFrequenciaAction extends Action {

    @Override
    public void prepararOperacao(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        try {

            int codTurma = Integer.parseInt(request.getParameter("codTurma"));
            request.setAttribute("turma", Turma.obterTurma(codTurma));

            List<Avaliacao> avaliacoes = Avaliacao.obterAvaliacoesPorTurma(codTurma);
            request.setAttribute("avaliacoes", avaliacoes);

            RequestDispatcher view = request.getRequestDispatcher("/manterNotaFrequencia.jsp");
            view.forward(request, response);

        } catch (ServletException e) {
            throw e;
        } catch (IOException e) {
            throw new ServletException(e);
        } catch (SQLException e) {
            throw new ServletException(e);
        } catch (ClassNotFoundException e) {
            throw new ServletException(e);
        }
    }

    @Override
    public void confirmarOperacao(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        
    }
}
